import axios from 'axios'
const service = axios.create({
    timeout: 5000,
})
// 请求拦截
service.interceptors.request.use(
    config => {
        // if (window.sessionStorage.getItem("token")) {
        //   config.headers['Authorization'] = window.sessionStorage.getItem("token")
        // }
        return config
    },
    error => {
        return Promise.reject(error)
    }
)
// 响应拦截
service.interceptors.response.use(
    response => {
        const res = response.data
        // if (res.code !== 0) {
        //   return Promise.reject(new Error(res.message || 'Error'))
        // } else {
        //   return res
        // }
        return res
    },
    error => {
        console.log('网络错误，请稍后再试！！');
        return Promise.reject(error)
    }
)
export default service


